<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('solr数据服务')"/>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="col-sm-12">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>榴莲题库</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-sm-2" style="align-self: center">
                                <button class="btn btn-success" onclick="updateQuestionData()">更新引擎数据</button>
                            </div>
                            <div class="col-sm-6">
                                <form class="form-horizontal m" id="question-update">
                                    <input type="text" class="form-control" placeholder="密钥key" name="key">
                                </form>
                            </div>
                        </div>
                        <br/>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<th:block th:include="include :: footer"/>
<script>

    const prefix = ctx + "es/dataServer";

    $("#question-update").validate({
        rules: {
            key: {
                required: true,
                minlength: 5,
                maxlength: 100
            },
        },
        focusCleanup: true
    });

    function updateQuestionData() {
        if ($.validate.form()) {
            const key = $("input[name='key']").val();
            $.ajax({
                cache: true,
                type: "POST",
                url: prefix+"/tiku/update-doc",
                data: {
                    "key": key
                },
                async: true,
                error: function (request) {
                    $.modal.alertError("系统错误");
                },
                success: function (data) {
                    $.operate.successCallback(data);
                }
            });
        }
    }
</script>
</html>
